﻿
@{
    Layout = "~/Views/Shared/_level2.cshtml";
}

<title>平台管理-待企业审核</title>
<link href="/SiteUI/CloudAdmin/share.css" rel="stylesheet" />
<link href="~/SiteUI/CloudAdmin/AcntApprove.css" rel="stylesheet" />
@section contentnavi{
    <div id="appTitle">
        云平台管理
    </div>
    <ul id="slideNavi">
        <li><a class="Lite" href="/CloudAdmin/PendingCompanyApprove"><i class="icon-wangluo1"></i>待审核企业<i class="icon-navigatenext arrow-go"></i></a></li>
        <li><a class="Lite" href="/CloudAdmin/CompanyApprove"><i class="icon-wangluo1"></i>已审核企业<i class="icon-navigatenext arrow-go"></i></a></li>
        <li><a class="Lite" href="/CloudAdmin/PendingAcntApprove"><i class="icon-wangluo1"></i>待审核账号<i class="icon-navigatenext arrow-go"></i></a></li>
        <li><a class="Lite" href="/CloudAdmin/AcntApprove"><i class="icon-wangluo1"></i>已审核账号<i class="icon-navigatenext arrow-go"></i></a></li>
    </ul>
}

<div class="header">
    <div class="col-lg-3 col-lg-offset-1 ">
        <input id="cx_input" placeholder="企业名称" />
    </div>
</div>
<div class="content">
    <div class="col-lg-10 col-lg-offset-1" id="tab_paging">
        <div class="row tab_title">
            <div class="col-lg-1"><h4>序号</h4></div>
            <div class="col-lg-3"><h4>企业名称</h4></div>
            <div class="col-lg-4"><h4>申请提交时间</h4></div>
            <div class="col-lg-2"><h4>用户名</h4></div>
            <div class="col-lg-2"><h4>联系方式</h4></div>
        </div>
        <div id="tab">
        </div>
        <div id="List-Paging" class="row tab_footer">
        </div>
    </div>
</div>
<div id="AccountDetails" style="display:none">
        <div class="col-lg-10 col-lg-offset-1">
            <div class="row  box_details">
                <div class="col-lg-3 col-lg-offset-1">企业名称:</div>
                <div class="col-lg-7"><input type="text" id="tl_company" /></div>
            </div>
            <div class="row  box_details">
                <div class="col-lg-3 col-lg-offset-1">组织机构代码:</div>
                <div class="col-lg-7"><input type="text" id="tl_bizorgcode" /></div>
            </div>
            <div class="row  box_details">
                <div class="col-lg-3 col-lg-offset-1">公商执照注册号:</div>
                <div class="col-lg-7"><input type="text" id="tl_licencecode" /></div>
            </div>
            <div class="row ">
                <div class="col-lg-3 col-lg-offset-1">营业执照:</div>
                <div class="col-lg-7">
                    <a id="seePic" target="_blank" href="../SiteUI/Imgs/bizlicence-example-big.jpg"><img id="tl_licencepic" src="../SiteUI/Imgs/bizlicence-example.jpg" /></a>
                </div>
            </div>
            <div class="row  box_details">
                <div class="col-lg-3 col-lg-offset-1">认证申请人:</div>
                <div class="col-lg-2" id="tl_name"></div>
                <div class="col-lg-2 col-lg-offset-1">联系电话:</div>
                <div class="col-lg-3" id="tl_phone"></div>
            </div>
            <div class="row  box_details">
                <div class="col-lg-3 col-lg-offset-1">申请时间:</div>
                <div class="col-lg-7" id="tl_applyTime"></div>
            </div>
            <div class="row  box_result">
                <div class="col-lg-3 col-lg-offset-1">*审查结果:</div>
                <div class="col-lg-7">
                    <select class="drop-down" id="tl_result">
                        <option value="positive">成功</option>
                        <option value="negative">失败</option>

                    </select>
                </div>
            </div>
            <div class="row " id="auditingOpinion" style="display:none">
                <div class="col-lg-3 col-lg-offset-1">*意见反馈:</div>
                <div class="col-lg-6">
                    <textarea id="tl_feedback"></textarea>
                </div>
            </div>
        </div>

</div>


<script>
  
    Certification = {
        Basic:null,
        WholeInfos: null,
        enterpriseData: function () {
            $.getJSON("/CloudAdmin/GetPendingCompany", null, function (rtn) {
                if (rtn.IsPositive) {
                    if (rtn.Data.Companies != undefined) {
                        Certification.WholeInfos = rtn.Data.Companies;
                        Certification.personal.vl(Certification.WholeInfos)
                                              .update();
                    }
                }
            })
        },  
     
        viewDetails: function (ev) {
            var id = $(ev.currentTarget).attr("data-id");
            var crt = Certification.WholeInfos.findObj("idstr", id);
            if (crt) {
                Certification.Basic = crt;
                $("#tl_company").vl(Certification.Basic.name);
                $("#tl_bizorgcode").vl(Certification.Basic.bizorgcode);
                $("#tl_licencecode").vl(Certification.Basic.licencecode);
                $("#seePic").attr("href", Certification.Basic.bizlicencepic);
                $("#tl_licencepic").attr("src", Certification.Basic.bizlicencepic);
                $("#tl_name").vl(Certification.Basic.submiter_realname || Certification.Basic.submiter_name);
                var d = new Date(Certification.Basic.createtime).format("yyyy/MM/dd hh:mm:ss");
                $("#tl_applyTime").vl(d);
                $("#tl_result").val("positive");
                $("#tl_phone").vl(Certification.Basic.officephone);
            }
            Certification.winSwitch();
        },
        winSwitch: function () {
            Certification.AccountDetails.RemoveBtn()
                                      .BtnEnter("确定", "", function () { Certification.AccountDetails.hide(); Certification.SubmittedResults(); })
                                      .BtnEsc("取消", "", function () { Certification.AccountDetails.hide() })
                                      .update()
                                      .show();
        },
        SubmittedResults: function () {
            var companyData = {};
            companyData.idstr = Certification.Basic.idstr;
            companyData.result = $("#tl_result").find("option:selected").val();
            companyData.name = $("#tl_company").vl();
            companyData.bizorgcode = $("#tl_bizorgcode").vl();
            companyData.licencecode = $("#tl_licencecode").vl();
            companyData.feedback = $("#tl_feedback").vl();
            console.log(companyData);
            $.post("/CloudAdmin/ApproveCompany", companyData, function (rtn) {
                if (rtn.IsPositive) {
                   Certification.enterpriseData();
                } else {
                    error("失败", "服务器正忙，请稍后重试");
                }

            });
       
        },
        checkDropdown: function () {
            if ($("#tl_result> option:selected").val() == "negative") {
                $("#auditingOpinion").show();
            }
            else {
                $("#auditingOpinion").hide();
            }
        }
    }
    $(function () {
        var navis = $("#slideNavi>li");
        for (var i = 0; i < navis.length; i++) {
            if (navis.eq(i).children("a").attr("href") == window.location.pathname) {
                navis.eq(i).addClass("current");
                break;
            }
        }
        Certification.enterpriseData();
        $("#tab").delegate(".tab_name", "click", Certification.viewDetails);
        Certification.paging = new LiberUI.Paging("#List-Paging")
                                          .option("Row", 20)
                                           .option("Total", 100)
                                          .option("BtnClick", function (a,b) {
                                              //分页控件
                                          })
                                          .update()
                                          .show();

        var sequence= 0;
        Certification.personal = new LiberUI.Lister("#tab")
                                            .option("ContentRender", function ($item, o) {
                                                sequence = sequence + 1;
                                                var html = $("<div class='row ' style='height:1.2rem; line-height: 2.5rem;'>");
                                                $("<div class='col-lg-1'>").vl(sequence).appendTo(html);
                                                $("<div class='col-lg-3 tab_name' data-id='"+o.idstr+"'>").vl(o.name).appendTo(html);
                                                var d = new Date(o.updatetime).format("yyyy/MM/dd hh:mm:ss");
                                                $("<div class='col-lg-4'>").vl(d).appendTo(html);
                                                $("<div class='col-lg-2'>").vl(o.submiter_name || o.submiter_phone).appendTo(html);
                                                $("<div class='col-lg-2'>").vl(o.officephone || submiter_phone).appendTo(html);
                                                $item.append(html);
                                            })
                                            .Loading("正在加载...");

        Certification.AccountDetails = new LiberUI.Dialoger()
                                     .Content($("#AccountDetails").show())
                                     .Title("认证信息")
                                     .option("MainStyle", "Small");
    })


</script>
